package com.cax.module.file.domain;


import java.time.LocalDateTime;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Set;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.IdType;
import lombok.Getter;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 文件表 实体
 * @author liangjian
 * @date 2023-11-24 16:52:24
 */
@Data
@TableName("file")
@ApiModel(value = "File", description = "文件表")
public class File extends Model<File> implements Serializable {

    @ApiModelProperty(value = "文件表-主键id")
	@TableId(value = "`id`", type = IdType.AUTO)
    private Long id;

	@ApiModelProperty(value = "文件录入类型 1系统上传 2手动维护文件表数据")
    @TableField("`enter_type`")
    private Integer enterType;

	@ApiModelProperty(value = "文件业务类型 来源file_type.id")
    @TableField("`file_type_id`")
    private Integer fileTypeId;

	@ApiModelProperty(value = "例如工单id 用户id等 id类型为int")
	@TableField("`relevance_int_id`")
	private Integer relevanceIntId;

	@ApiModelProperty(value = "例如工单id 用户id等 id类型为Long")
	@TableField("`relevance_long_id`")
	private Long relevanceLongId;

	@ApiModelProperty(value = "例如工单id 用户id等 id类型为String")
	@TableField("`relevance_str_id`")
	private String relevanceStrId;

	@ApiModelProperty(value = "在minio中 文件存储的桶名称")
	@TableField("`bucket`")
	private String bucket;

	@ApiModelProperty(value = "文件在minio桶中的位置")
	@TableField("`url`")
	private String url;

	@ApiModelProperty(value = "文件上传的原名称")
	@TableField("`original_name`")
	private String originalName;

	@ApiModelProperty(value = "文件名称 手动维护的一般是自定义的名称 通过系统上传的是uuid")
    @TableField("`name`")
    private String name;

	@ApiModelProperty(value = "文件后缀")
    @TableField("`suffix`")
    private String suffix;

	@ApiModelProperty(value = "备注")
    @TableField("`remarks`")
    private String remarks;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("`create_time`")
    private LocalDateTime createTime;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("`update_time`")
    private LocalDateTime updateTime;

    @TableField("`delete_flag`")
    private Integer deleteFlag;


	@ApiModelProperty(value = "文件在网络上的访问地址")
	@TableField(exist = false)
	private String accessUrl;



	/**Enum 文件上传方式**/
	@Getter
	public enum EnumEnterType {
		SYSTEM(1,"系统上传"),
		HAND_MOVEMENT (2,"手动上传");

		private Integer enterType;
		private String enterTypeName;

		EnumEnterType(Integer enterType,String enterTypeName) {
			this.enterType = enterType;
			this.enterTypeName = enterTypeName;
		}
	}

	/**文件类型**/
	public static Set<String> fileSuffix = ImmutableSet.of(
			"jpg","png","gif","jpeg",
			"txt",
			"pdf",
			"ppt",
			"doc","docx",
			"xls","xlsx",
			"mp3","mp4",
			"amr",
			"speex"
	);

}

